import axios from "axios";

const token = sessionStorage.getItem("authentication");

export const insertAddress = (data: any) =>
    axios({
        url: "api/user/addressBook",
        method: 'post',
        headers: {authentication: token},
        data: data
    })

export const getAddressList = () =>
    axios({
        url: "api/user/addressBook/list",
        method: 'get',
        headers: {authentication: token},
    })

export const getDefault = () =>
    axios({
        url: "api/user/addressBook/default",
        method: 'get',
        headers: {authentication: token},
    })

export const setDefault = (id: any) =>
    axios({
        url: "api/user/addressBook/default",
        method: 'put',
        headers: {authentication: token},
        params: {id: id}
    })

export const getAddressById = (id: any) =>
    axios({
        url: `api/user/addressBook/${id}`,
        method: 'get',
        headers: {authentication: token},
    })

export const deleteAddressById = (id: any) =>
    axios({
        url: "api/user/addressBook",
        method: 'delete',
        headers: {authentication: token},
        params: {id: id}
    })
